/**  
 * @Project: Dawn
 * @Title: RequestDataManager.java
 * @Package manager
 * @Description: Test Data Processor
 * @author yanglei yanglei1@funshion.com
 * @date 2014年12月3日 上午11:05:09
 * @Copyright: 2014 funshion.com. All rights reserved.
 * @version V1.0  
 */
package processor.dataobject;

import util.XMLSerializer;
import util.XmlParser;
import dataobject.DataObject;
import dataobject.EnumData;
import dataobject.request.Request;
import dataobject.teststeps.TestCase;

/**
 * @ClassName RequestDataManager
 * @Description Test Data Processor
 * @author yanglei1 yanglei1@funshion.com
 * @date 2014年12月3日
 */
public class TestDataProcessor extends DataProcessor {

	/**
	 * @param dataObject
	 */
	public TestDataProcessor() {

	}

	public Object getData(EnumData data, String dataPath, String attributeValue) {
		DataObject dataObject = null;
		switch (data.ordinal()) {
		// Request Data Object
		case 0:
			try {
				XmlParser xmlParser = new XmlParser(dataPath);
				String requestStr = xmlParser.getElementByID(
						"AllRequests/Request", attributeValue).asXML();
				XMLSerializer xmlSerializer = new XMLSerializer(requestStr);
				dataObject = (Request) xmlSerializer.xmlToObject(Request.class);
			} catch (Exception e) {
				e.printStackTrace();
			}
			break;
		// Test Case Data Object
		case 1:
			try {
				XmlParser xmlParser = new XmlParser(dataPath);
				String requestStr = xmlParser.getElementByID("AllTestSteps/TestCase", attributeValue).asXML();
				XMLSerializer xmlSerializer = new XMLSerializer(requestStr);
				dataObject = (TestCase) xmlSerializer.xmlToObject(TestCase.class);
			} catch (Exception e) {
				e.printStackTrace();
			}
			break;
		}
		return dataObject;
	}
}